package study.javabasic.communication.WhileCom;

import java.util.List;

/**
 * Created by zhangshuhan on 2019/3/20.
 */
public class ThreadA implements Runnable {

    List<String> list;


    public ThreadA(List<String> list) {
        this.list = list;
    }

    @Override
    public void run() {
        System.out.println("线程1启动");
        for (int i = 0; i < 10; i++) {
            list.add("a");
            System.out.println("线程1添加" + i + "个元素");
            try {
                if (i == 4) {
                    Thread.sleep(1000);
                } else {
                    Thread.sleep(1000);
                }
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
        }
        System.out.println("线程1完成任务退出");
    }
}
